#操作系统接口
print("操作系统接口")

import os_learn
cwd = os_learn.getcwd()
print(cwd)
#dir = os.chdir("")  #修改当前目录
#print(dir)
os_learn.system("mkdir today")  #创建目录


#文件通配符
print("文件通配符")
import glob
flist = glob.glob("*.py")
print(".py文件列表：", flist)

#命令行参数
print("命令行参数")
import sys
print(sys.argv)

#错误输出重定向和程序终止
print("错误输出重定向和程序终止")
sys.stderr.write('Warning, log file not found starting a new one\n')



#数学
print("数学")
import math
va = math.cos(math.pi/4)
print(va)
lo = math.log(1024,2)
print(lo)

import random
ra = random.choice(["apple", "pear", "banana"]) #随机选择一个
print(ra)
ra2 = random.sample(range(100), 10)  #10个100以内的数
print(ra2)
ra3 = random.random()  #随机浮点数
print(ra3)
ra4 = random.randrange(6)  #6以内的随机数
print(ra4)


#访问 互联网
print("访问 互联网")
from urllib.request import urlopen
for line in urlopen("https://www.baidu.com"):
    line = line.decode("utf-8")
    if "est" in line or "edt" in line:
        print(line)

#日期和时间
print("日期和时间")
from datetime import date
now = date.today()
print(now)
strt = now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.")
print(strt)
#dt = datetime.date(2003,12,12)
#print(dt)

#打包
print("打包")
import zlib
s = b'witch which has which witches wrist watch'
print(len(s))
t = zlib.compress(s)
print(len(t))
zli = zlib.decompress(t)
z = zlib.crc32(s)
print(z)